package com.goods.controller.busniess;

import com.github.pagehelper.PageInfo;
import com.goods.business.service.OutStockService;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.ConsumerVO;
import com.goods.common.vo.business.OutStockDetailVO;
import com.goods.common.vo.business.OutStockVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @description：
 * @version: 出库
 * @author：ruixinag
 * @create：Created in 2021/11/9 16:53
 */
@Api(tags = "业务模块-出库")
@RestController
@RequestMapping("/business/outStock")
public class OutStockController {
    @Autowired
    private OutStockService outStockService;

    //1.出库单（发放记录）数据分页列表展示
    @ApiOperation("物资去处分页列表展示")
    @GetMapping("/findOutStockList")
    public ResponseBean findOutStockList(@RequestParam Map paramMap){
        Map map=outStockService.findOutStockList(paramMap);

        return ResponseBean.success(map);
    }

    //2.查看出库明细
    @ApiOperation("查看出库明细")
    @GetMapping("/detail/{outStackId}")
    public ResponseBean<OutStockDetailVO> detail(@PathVariable Long outStackId,Integer pageNum){

       OutStockDetailVO outStockDetailVO= outStockService.detail(pageNum, outStackId);
        return ResponseBean.success(outStockDetailVO);
    }

    //3.新增出库单 addOutStock
    @ApiOperation("新增出库单")
    @PostMapping("/addOutStock")
    public ResponseBean addOutStock(@RequestBody OutStockVO outStockVo){

        outStockService.addOutStock(outStockVo);
        return ResponseBean.success();
    }

    //4.审核通过,增加库存 publish
    @ApiOperation("审核通过")
    @PutMapping("/publish/{outStockId}")
    public ResponseBean publish(@PathVariable Long outStockId){

        outStockService.publish(outStockId);
        return ResponseBean.success();
    }

    //5.移动回收站 remove
    @ApiOperation("移动回收站")
    @PutMapping("/remove/{outStockId}")
    public ResponseBean remove(@PathVariable Long outStockId){

        outStockService.remove(outStockId);
        return ResponseBean.success();
    }

    //6.还原 back
    @ApiOperation("还原")
    @PutMapping("/back/{outStockId}")
    public ResponseBean back(@PathVariable Long outStockId){

        outStockService.back(outStockId);
        return ResponseBean.success();
    }

    //7 删除 delete
    @ApiOperation("删除")
    @GetMapping("/delete/{outStockId}")
    public ResponseBean delete(@PathVariable Long outStockId){

        outStockService.delete(outStockId);
        return ResponseBean.success();
    }

}
